package com.noreply.springannotation;

import com.noreply.springannotation.bean.Color;
import com.noreply.springannotation.bean.User;
import com.noreply.springannotation.config.CarConfig;
import com.noreply.springannotation.config.CatConfig;
import com.noreply.springannotation.config.Config;
import com.noreply.springannotation.config.UserConfig;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author noreply
 * @description
 */
public class IOCTestLifeCycle {
    @Test
    public void testScope() {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(CarConfig.class);

    }

    @Test
    public void testCat() {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(CatConfig.class);

    }

    @Test
    public void testFactoryBean() {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Config.class);
        // 拿到的是Color
        Object object = applicationContext.getBean("colorFactoryBean");
        System.out.println(object.getClass());

        // 拿到的是ColorFactoryBean
        Object object2 = applicationContext.getBean("&colorFactoryBean");
        System.out.println(object2.getClass());
    }
}
